﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeGenerator.Core
{
    /// <summary>
    /// 数据库配置信息
    /// </summary>
    public class ServerInfo
    {
        /// <summary>
        /// 别名
        /// </summary>
        public string Alias { get; set; }

        /// <summary>
        /// 数据库类型
        /// </summary>
        public string DatabaseType { get; set; }

        /// <summary>
        /// 服务器
        /// </summary>
        public string ServerName { get; set; }

        /// <summary>
        /// 连接字符串
        /// </summary>
        public string ConnectString { get; set; }

        /// <summary>
        /// 默认数据库
        /// </summary>
        public string DatabaseName { get; set; }

        public DatabaseType DBType
        {
            get
            {
                switch (DatabaseType)
                {
                    case "SqlServer":
                        return Core.DatabaseType.SqlServer;
                    case "Sqlite":
                       return Core.DatabaseType.Sqlite;
                    case "MySql":
                       return Core.DatabaseType.MySql;
                    case "Oracle":
                       return Core.DatabaseType.Oracle;
                    case "PostgreSQL":
                       return Core.DatabaseType.PostgreSQL;
                    default:
                       return Core.DatabaseType.SqlServer;
                }
            }
        }
    }
}
